home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NT Sources
/
Infomagic - NT Source Volume 1 (Disc 1 of 2).iso
/
network
/
pcdctrla.exe
/
PCDCTRL.EXE
/
PCDCUS.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1997-09-08
|
16KB
|
387 lines
$! PCDUO_CUSTOM.COM
$! Turn off verify unless lu$verify is defined, in which case we don't change it
$ If F$Type (lu$verify) .eqs. "" then verify = F$Verify (0)
$! And establish any debugging states
$ dbgsay = "!" ! Assume no debugging
$ If F$Type (lu$debug) .nes. "" then dbgsay = "Write SYS$OUTPUT"
$!------------------------------------------------------------------------------
$!
$! This command procedure is called by LANdist's -CUSTOM: mechanism to control
$! the customisation of a PC-Duo installation.
$!
$! Copyright (c) 1994-1997, Vector Networks Ltd. All Rights Reserved.
$!
$! PCDUO_CUSTOM.COM - Command Procedure to customise a PC-Duo installation.
$!
$! This command procedure makes the following assumptions:-
$!
$! 1 - As LANdist has already copied the PCDUO directory tree, we assume that
$! the PC is accessible, so we don't check the global symbols here...
$! 2 - The initial LANdist was carried out with an interlock list that ensures
$! the target PC is currently not running Windows.
$! 3 - This command procedure does not specify any network adapter name(s) or
$! passwords that may be required to access the master or target PCs.
$! 4 - The target PC PC-Duo directory has the same name and is on the same
$! disk drive as the source PC (i.e. C:\PCDUO).
$! 5 - If the target PC is running Windows for Workgroups, then it must
$! be idle (ideally with no applications open). The edit scripts for
$! PC-Duo are mostly WFW-aware, but the PC configuration can be damaged
$! if Windows is started or stopped while this script is running.
$!
$! Revision History :
$! 0.0 14-Jun-94 DB - Created.
$! 16-Jun-94 DB - Add loops to edit all PROGMAN.INI, PROTOCOL.INI,
$! WIN.INI, and CFG*.TPL template files found
$! 1.02 11-Nov-94 DB - Correct reference to PATHWORKS 5 default directory.
$! 2.02 10-Apr-95 DB - Update for installation of or upgrades to v2.02.
$! 25-Apr-95 DB - Enable LANrendir calls to rename the PCDUO directories.
$! 24-May-95 SB - Switched to LANdist's -CUSTOM: interface.
$! 2.21 06-Jun-95 SB - Improve batch job output traceability.
$! 2.22 04-Sep-95 DB - Updated for PC-Duo v2.1
$! 2.3 16-May-96 DB - Updated for PC-Duo v3.02, to support Windows 95.
$! This requires LANutil 2.3 (long file name support).
$! 3.1 04-Jul-97 DB - Copy PCDVGA.DRV from the source PC's WINDOWS\SYSTEM
$! directory. This may not work if a Client is running.
$!------------------------------------------------------------------------------
$
$! The initial LANdist command has copied the \PCDUO directory tree from the
$! master PC \\'pcd_source'\PCDUO.NEW. This is to avoid overwriting an existing
$! PC-Duo installation. We have to configure Windows to install the PC-Duo
$! drivers, add the Program Manager Group, run the Windows Client, and
$! set NetHeapSize.
$!
$! Previous version(s) used a call to STARTSLV.BAT in either AUTOEXEC.BAT or a
$! PATHWORKS 5 template file to start the DOS Slave TSR. STARTSLV.BAT has been
$! superseded in v2.02 by STARTTSR.BAT, but a dummy version of STARTSLV.BAT is
$! provided which will call STARTTSR.BAT, if it exists. If the DOS TSR is still
$! required, no further action need be carried out. If the DOS TSR is not
$! required, then STARTSLV.BAT can be deleted from the Master PC. Provided that
$! the recommended calling procedure has been used, removing STARTSLV.BAT will
$! simply result in no TSRs being loaded.
$!
$! Similarly, we check any PROTOCOL.INI files found to make sure that the
$! real-mode NetBEUI NCBS and SESSIONS values are high enough for reliable
$! operation.
$
$ Say := Write SYS$OUTPUT
$ Put := Type SYS$INPUT
$
$! Take control of errors.
$
$ Set noon ! We will handle any errors, thanks
$
$! on ERROR then goto INCOMPLETE
$
$ on CONTROL_Y then goto INTERRUPT
$
$! Initialise local variables
$
$ lustatus = 0 ! Exit status
$
$! LANdist provides us with the following symbols:-
$!
$! lut_ipspec = PC\RESOURCE ! Source PC with any LAN/user/pwd
$! lut_pcspec = PC\RESOURCE ! Target PC with any LAN/user/pwd
$! lut_mailuser = ?? ! Error notification Mail to User
$
$! Show what we actually got :
$
$ dbgsay "LANdist parameters : "
$ dbgsay " lut_ipspec = ''lut_ipspec'"
$ dbgsay " lut_pcspec = ''lut_pcspec'"
$ dbgsay " lut_mailuser = ''lut_mailuser'"
$
$! We now have all of the input parameters needed.
$
$! If the target PC is running PATHWORKS 5 or 6, then we can load the PC-Duo
$! DOS Client TSR by adding a call to STARTSRV.BAT in the [User Commands]
$! section of the active template(s). This is only done here if we do not find
$! a WINDOWS directory. The default behaviour is to load the Windows Client
$! when Windows starts up. It is safe to load both DOS and Windows Clients.
$! This is necessary when a Client must be accessible when it is running
$! DOS, as well as Windows.
$
$ Say "LANtest \\''lut_pcspec'\WINDOWS\"
$ LANtest \\'lut_pcspec'\WINDOWS\
$ lustatus = $Status
$
$! To change the default behaviour and load the PC-Duo DOS Client TSR,
$! comment out the following line.
$
$ If lustatus then goto AUTOEXEC_DONE
$
$! Search for and edit all PATHWORKS template(s) on the target PC.
$
$ EDIT_TEMPLATE:
$ Say ""
$ Say "Arranging for PATHWORKS to load the PC-Duo Client during network startup"
$
$! Now, define some symbols for use by the loop-for-all-files subroutine.
$! We define input_file_spec and edit_file_spec.
$
$ input_file_spec := "\PW\CFG*.TPL"
$ edit_file_spec := "PCDUO_template.tpu"
$
$ gosub MULTI_EDIT
$
$! If no matching files were found, lustatus will be set to SS$_NOSUCHFILES.
$! Skip to the edit AUTOEXEC.BAT section.
$
$ If lustatus then goto AUTOEXEC_DONE
$
$ TEMPLATE_DONE:
$ on CONTROL_Y then goto INTERRUPT ! Re-instate the Control-Y handler
$
$! If no PATHWORKS 5 templates were found, it may be possible to start the
$! PC-Duo DOS Client TSR by adding a line to the end of the AUTOEXEC.BAT file.
$! This is not done here, as we default to using the Windows Client only.
$! This edit can be enabled by commenting out the following line.
$
$ goto AUTOEXEC_DONE
$
$ Say "Editing file \\''lut_pcspec'\AUTOEXEC.BAT"
$
$ Say "LANedit \\''lut_pcspec'\AUTOEXEC.BAT -command:PCDUO_autoexec.tpu"
$ LANedit \\'lut_pcspec'\AUTOEXEC.BAT -command:PCDUO_autoexec.tpu
$
$ lustatus = $Status
$ If $Status then goto AUTOEXEC_DONE
$ Say "Error ''lustatus' occurred editing the AUTOEXEC.BAT. Exiting."
$ goto TIDY_EXIT
$
$! Here, we have finished (or skipped) the edit(s) to load the DOS TSR.
$
$ AUTOEXEC_DONE:
$
$! Before configuring Windows (if present), we look in the PCDUO directory
$! on the target PC to see if there is anything there that we want to keep.
$
$ Say "LANtest \\''lut_pcspec'\PCDUO\"
$ LANtest \\'lut_pcspec'\PCDUO\
$ lustatus = $Status
$
$ If .not. lustatus then goto DO_WINDOWS
$
$! We try to preserve the Dial Directory from a previous installation.
$! Use LANcopy -n so that we don't overwrite new files with old ones.
$
$ Say "LANcopy \\''lut_pcspec'\PCDUO\CONTROL.DIR \\''lut_pcspec'\PCDUO.NEW\ -n -q"
$ LANcopy \\'lut_pcspec'\PCDUO\CONTROL.DIR \\'lut_pcspec'\PCDUO.NEW\ -n -q
$
$! We also copy any Client Files (*.CLF and *.GLF) from a v2.x installation.
$
$ Say "LANcopy \\''lut_pcspec'\PCDUO\*.?LF \\''lut_pcspec'\PCDUO.NEW\ -n -q"
$ LANcopy \\'lut_pcspec'\PCDUO\*.?LF \\'lut_pcspec'\PCDUO.NEW\ -n -q
$
$ DO_WINDOWS:
$
$! Next, we update the target PC's Windows setup. If the target PC is running
$! Windows 3.1 or Windows for Workgroups, we have to edit PROGMAN.INI and
$! SYSTEM.INI to install PC-Duo. We must also check WIN.INI in case it
$! contains a run=wslave command from PC-Duo v1.xx. We could also check the
$! PROTOCOL.INI file to make sure that it is configured correctly.
$!
$! If the source and target PCs are running Windows 95, then we only have to
$! edit SYSTEM.INI (and WIN.INI). Windows 95 does have a PROTOCOL.INI, but
$! the edits we make to NetBEUI should really be done in the Registry, key
$! HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\NETBEUI\Ndi\params
$
$! This section is not necessary if the target PCs are not running Windows.
$
$ Say "LANtest \\''lut_pcspec'\WINDOWS\"
$ LANtest \\'lut_pcspec'\WINDOWS\
$ lustatus = $Status
$
$ If .not. lustatus then goto WINDOWS_DONE
$
$! We need to distinguish between Windows 3.1/3.11 and Windows 95. For the
$! former, we copy the PCDUO.GRP group file and set up PROGMAN.INI. For the
$! latter, we simply copy the Shortcuts from the source PC. We look for them
$! in directory "\WINDOWS\Start Menu\Programs\PC-Duo". We test for this
$! directory on the Source PC. This sequence requires LANutil 2.3.
$
$ Say "LANdir ""\\''lut_ipspec'\windows\Start Menu\Programs\PC-Duo\*.lnk -q"""
$ LANdir "\\''lut_ipspec'\windows\Start Menu\Programs\PC-Duo\*.lnk"" -q
$
$ If .not. $Status then goto REGULAR_WINDOWS
$
$! Check the target PC as well...
$
$ Say "LANdir ""\\''lut_pcspec'\windows\Start Menu\Programs\*.* -q"""
$ LANdir "\\''lut_pcpec'\windows\Start Menu\Programs\*.*" -q
$
$ If .not. $Status then goto REGULAR_WINDOWS
$
$ Say ""
$ Say "Configuring WINDOWS 95 for PC-Duo"
$
$ Say "LANcopy ""\\''lut_ipspec'\windows\Start Menu\Programs\PC-Duo\*.lnk \\''lut_pcspec' -b -o -x -q"""
$ LANcopy "\\''lut_ipspec'\windows\Start Menu\Programs\PC-Duo\*.lnk" \\'lut_pcspec' -b -o -x -q
$ lustatus = $Status
$ If .not. $Status then goto TIDY_EXIT
$
$ goto WINDOWS_COMMON
$
$ REGULAR_WINDOWS:
$
$ Say ""
$ Say "Configuring WINDOWS 3.xx for PC-Duo"
$
$! We need to copy the PC-Duo Group File PCDUO.GRP onto the target PC.
$
$ Say ""
$ Say "Copying the PC-Duo Group File to \\''lut_pcspec'\WINDOWS :"
$
$ Say "LANcopy \\''lut_ipspec'\windows\pcduo.grp \\''lut_pcspec' -b -o -x -q"
$ LANcopy \\'lut_ipspec'\windows\pcduo.grp \\'lut_pcspec' -b -o -x -q
$ lustatus = $Status
$ If .not. lustatus then goto TIDY_EXIT
$
$! Next, edit PROGMAN.INI to add the PC-Duo Group.
$
$! The changes will take effect the next time Windows is started.
$
$! Add the PC-Duo Group to the Program Manager Desktop
$
$ Say "LANedit \\''lut_pcspec'\WINDOWS\PROGMAN.INI -command:PCDUO_progman_ini.tpu"
$ LANedit \\'lut_pcspec'\WINDOWS\PROGMAN.INI -command:PCDUO_progman_ini.tpu
$
$! We also need to make sure that the target PC has copies of CTL3DV2.DLL and
$! PROCHOOK.DLL. We can't use -u update, because we can't rely on the input
$! file rev-date (typically set to the package release date and version).
$
$ WINDOWS_COMMON:
$
$ Say "LANcopy \\''lut_ipspec'\windows\system\ctl3dv2.dll \\''lut_pcspec' -b -o -n -x -q"
$ LANcopy \\'lut_ipspec'\windows\system\ctl3dv2.dll \\'lut_pcspec' -b -o -n -x -q
$ Say "LANcopy \\''lut_ipspec'\windows\system\prochook.dll \\''lut_pcspec' -b -o -n -x -q"
$ LANcopy \\'lut_ipspec'\windows\system\prochook.dll \\'lut_pcspec' -b -o -n -x -q
$
$! Try to copy PCDVGA.DRV from the source PC. The output file may be locked
$! if there is a PC-Duo Client running already.
$
$ Say "LANcopy \\''lut_ipspec'\windows\system\pcdvga.drv \\''lut_pcspec' -b -o -u -x -q"
$ LANcopy \\'lut_ipspec'\windows\system\pcdvga.drv \\'lut_pcspec' -b -o -u -x -q
$
$! That completes the copying.
$
$! Some NDIS network transports require additional configuration to support
$! efficient PC-Duo operation. For example, Windows for Workgroups, running
$! on a NetBEUI transport, requires additional SESSIONS and NCBS to be
$! allocated in the PROTOCOL.INI. This is done by the following edit.
$! Activate this edit by removing the comment ! character.
$
$! Say "LANedit \\''lut_pcspec'\WINDOWS\PROTOCOL.INI -command:PCDUO_protocol_ini.tpu"
$! LANedit \\'lut_pcspec'\WINDOWS\PROTOCOL.INI -command:PCDUO_protocol_ini.tpu
$
$! Next, we reconfigure the Windows Display Drivers, load the Windows Client
$! and check the NetHeapSize. These are done by editing SYSTEM.INI.
$
$ Say "LANedit \\''lut_pcspec'\WINDOWS\SYSTEM.INI -command:PCDUO_system_ini.tpu"
$ LANedit \\'lut_pcspec'\WINDOWS\SYSTEM.INI -command:PCDUO_system_ini.tpu
$
$! Lastly, we tidy up in the case where Windows was configured to load the
$! PC-Duo v1.02 Windows Slave program when it starts up. The new Windows
$! Client is loaded from the SYSTEM.INI [boot] wclient= line instead.
$
$ Say "LANedit \\''lut_pcspec'\WINDOWS\WIN.INI -command:PCDUO_win_ini.tpu"
$ LANedit \\'lut_pcspec'\WINDOWS\WIN.INI -command:PCDUO_win_ini.tpu
$
$! Windows configuration is complete.
$
$ WINDOWS_DONE:
$
$! Lastly, we have to move the old PCDUO directory out of the way. We can't
$! delete its contents until the PC reboots if the Windows Slave is running
$! or the Windows drivers (e.g. PCDVGA.DRV) are loaded.
$
$ Say "LANrendir \\''lut_pcspec'\PCDUO \PCDUO.OLD -q"
$ LANrendir \\'lut_pcspec'\PCDUO \PCDUO.OLD -q
$ Say "LANrendir \\''lut_pcspec'\PCDUO.NEW \PCDUO -q"
$ LANrendir \\'lut_pcspec'\PCDUO.NEW \PCDUO -q
$ lustatus = $Status
$
$ goto TIDY_EXIT
$
$ INTERRUPT:
$ lustatus = 8372 ! SS$_OPRABORT
$ goto TIDY_EXIT
$
$ INCOMPLETE:
$ lustatus = 724 ! SS$_OPINCOMPL
$
$! All done
$
$ TIDY_EXIT:
$ If F$TrnLnm ("list_file") .nes. "" then close list_file
$ If F$Type (lu$verify) .eqs. "" then verify = F$Verify (verify)
$ Say ""
$ Say "PCDUO_CUSTOM.COM exiting with status ''lustatus'."
$ If .not. lustatus then dbgsay F$Message (lustatus)
$ Exit lustatus
$
$! Subroutines:
$
$! MULTI_EDIT is a subroutine which is used to find all files on the
$! target PC which match an input wildcard file spec. It searches for all
$! matching file(s) on the target PC, getting their paths (and names) into a
$! temporary list file. It then loops through the list file, assembling the
$! target file paths, and calling LANedit to edit them using the edit command
$! file specified by edit_file_spec.
$
$ MULTI_EDIT:
$ list_file_name = "PCD_''F$Getjpi ("", "PID")'.LST"
$ LANdirectory \\'lut_pcspec''input_file_spec' -b -o:'list_file_name' -s -z:pn
$
$ lustatus = $Status
$ If .not. lustatus then goto MULTI_END
$
$ open/read/error=MULTI_OPEN_ERROR list_file 'list_file_name'
$
$ on CONTROL_Y then goto MULTI_INTERRUPT_CLOSE
$
$! The file contains a list of tree-relative paths. We append each one onto the
$! PC\RESOURCE in lut_pcspec, and fire off a LANedit to update them.
$
$ MULTI_READ_LOOP:
$ read/end_of_file=MULTI_END/error=MULTI_READ_ERROR list_file file_line
$
$ dbgsay "Line read <''file_line'>"
$
$ Say "LANedit \\''lut_pcspec'''file_line' -command:''edit_file_spec'"
$ LANedit \\'lut_pcspec''file_line' -command:'edit_file_spec'
$
$ lustatus = $Status
$ If lustatus then goto MULTI_READ_LOOP
$
$ Say ""
$ Say "Unexpected Error ''lustatus' reported editing \\''lut_pcspec'''file_line'."
$ goto TIDY_EXIT
$
$ MULTI_OPEN_ERROR:
$ lustatus = $Status
$ Say ""
$ Say "Unexpected Error ''lustatus' opening temporary file ''list_file_name'. Exiting"
$ goto TIDY_EXIT
$
$ MULTI_READ_ERROR:
$ lustatus = $Status
$ Say ""
$ Say "Unexpected Error ''lustatus' reading temporary file ''list_file_name'. Exiting"
$ close list_file
$ goto TIDY_EXIT
$
$ MULTI_INTERRUPT_CLOSE:
$ lustatus = 8372 ! SS$_OPRABORT
$ on CONTROL_Y then goto TIDY_EXIT ! Re-instate the Control-Y handler
$ close list_file
$ goto TIDY_EXIT
$
$ MULTI_END:
$ If F$TrnLnm ("list_file") .nes. "" then close list_file
$ delete/nolog/noconfirm 'list_file_name';*
$
$ MULTI_DONE:
$ on CONTROL_Y then goto TIDY_EXIT ! Re-instate the Control-Y handler
$ return ! and return